package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.jy.modules.cims.data.common.dao.TCMmCreditPackageDao;
import com.jy.modules.cims.data.common.dto.TCMmCreditPackageDTO;
import com.jy.platform.core.common.BaseDTO;


/**
 * @classname: TCMmCreditPackageService
 * @description: 定义  债权包 实现类
 * @author:  zhiqiang
 */
@Service("com.jy.modules.cims.component.common.service.TCMmCreditPackageService")
public class TCMmCreditPackageService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmCreditPackageDao dao;

	/**
     * @author zhiqiang
     * @description: 分页查询 债权包列表
     * @date 2015-01-07 16:20:41
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmCreditPackageDTO> searchTCMmCreditPackageByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmCreditPackageDTO> dataList =  dao.searchTCMmCreditPackageByPaging(searchParams);
		return dataList;
	}
	/**
     * @author zhiqiang
     * @description: 按条件查询债权包列表
     * @date 2015-01-07 16:20:41
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmCreditPackageDTO> searchTCMmCreditPackage(Map<String,Object> searchParams) throws Exception {
	    List<TCMmCreditPackageDTO> dataList = dao.searchTCMmCreditPackage(searchParams);
        return dataList;
    }
	/**
     * @author zhiqiang
     * @description: 查询债权包对象
     * @date 2015-01-07 16:20:41
     * @param id
     * @return
     * @throws
     */ 
	public TCMmCreditPackageDTO queryTCMmCreditPackageByPrimaryKey(String id) throws Exception {
		
		TCMmCreditPackageDTO dto = dao.findTCMmCreditPackageByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmCreditPackageDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmCreditPackage
     * @author zhiqiang
     * @description: 新增 债权包对象
     * @date 2015-01-07 16:20:41
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmCreditPackage(TCMmCreditPackageDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmCreditPackage(paramMap);
		
		TCMmCreditPackageDTO resultDto = (TCMmCreditPackageDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmCreditPackage
     * @author zhiqiang
     * @description: 修改 债权包对象
     * @date 2015-01-07 16:20:41
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmCreditPackage(TCMmCreditPackageDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmCreditPackage(paramMap);
	}
	
	/**
     * @title: updateTCMmCreditPackage
     * @author zhoupeng
     * @description: 修改 债权包对象
     * @date 2016-05-09 16:20:41
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmCreditPackageByPackageName(TCMmCreditPackageDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmCreditPackageByPackageName(paramMap);
	}
	/**
     * @title: deleteTCMmCreditPackageByPrimaryKey
     * @author zhiqiang
     * @description: 删除 债权包,按主键
     * @date 2015-01-07 16:20:41
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmCreditPackageByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmCreditPackageByPrimaryKey(paramMap);
	}
	
	/**
	 * 验证包是否可以删除
	 * @param paramMap
	 * @throws Exception
	 */
	public List<TCMmCreditPackageDTO> deleteTCMmCreditPackageIsExsit(Map<String, Object> paramMap) throws Exception {
		
		List<TCMmCreditPackageDTO> list = dao.deleteTCMmCreditPackageIsExsit(paramMap);
		
		return list;
	}

}

